package net.sxjr.protal.user;

import net.sxjr.common.Response;
import net.sxjr.protal.user.dao.LoginUserInfo;
import net.sxjr.protal.user.service.LoginService;
import net.sxjr.protal.user.service.SmsManageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：cuixc
 * @date ：Created in 2020/12/11 16:03
 * @description：消息通知模块
 * @modified By：
 */
@RestController
@RequestMapping("/smsmanage")
public class SmsManageController {
    @Autowired
    private SmsManageService smsManageService;
    @Autowired
    private LoginService loginService;
    @GetMapping("/list")
    public Response list(@RequestParam(value = "size", defaultValue = "5") Integer size,
                         @RequestParam(value = "current", defaultValue = "1") Integer current){
        LoginUserInfo currentUser = loginService.getCurrentUser();
        return smsManageService.list(size,current,currentUser.getAccount());
    }

    @GetMapping("/read")
    public Response read(@RequestParam String smsId){
        return smsManageService.read(smsId);
    }

    //在每个环节中   消息详情
    @GetMapping("/readSmsFromLinkCode")
    public Response readSmsFromLinkCode(@RequestParam(required = false) String linkCode,@RequestParam(required = false) String superviseCode){
        if(StringUtils.isBlank(linkCode) || StringUtils.isBlank(superviseCode)){
            return Response.success();
        }
        return smsManageService.readSmsFromLinkCode(linkCode,superviseCode);

    }
}
